﻿Imports Telerik.Web.UI
Imports System.Data

Partial Class ContentMasterPage
    Inherits System.Web.UI.MasterPage

    Dim Form As UserControl
    Dim Grid As RadGrid

    Dim EmpObj As New DBEmployeeSP
    Dim EmpDatatset As New Data.DataSet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("UserInfo") Is Nothing Then
            Response.Redirect("~/login.aspx")
        Else
            Dim SESCLASS As New SessionClass
            SESCLASS = Session("UserInfo")
            lblUserName.Text = SESCLASS.getFullName

            Dim id As String = SESCLASS.getUserID

            odsMenu.SelectParameters("ID").DefaultValue = id

        End If


    End Sub


    Protected Sub rmMain_ItemDataBound(ByVal sender As Object, ByVal e As RadMenuEventArgs)
        If (e.Item.Value = "Tools") Then
            e.Item.PostBack = False
            e.Item.ImageUrl = "Design/arrow_down.png"
            e.Item.ExpandedImageUrl = "Design/arrow_up.png"
        End If

        If (e.Item.Value = "Logout") Then
            e.Item.ImageUrl = "Design/Logout-Gray.png"
            e.Item.CssClass = "LogoutImage"
            e.Item.Visible = False
        End If
    End Sub


    Protected Sub rmMain_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles rmMain.ItemClick

        Dim MenuSelectedItemstr As String
        MenuSelectedItemstr = e.Item.Value

        Dim langAr As String = "ar-JO"
        Dim langEn As String = "En-GB"

        If Not (Request.Cookies("Language") Is Nothing) AndAlso Not (Request.Cookies("Language").Value Is Nothing) Then


            If MenuSelectedItemstr = "Logout" Then
                FormsAuthentication.SignOut()
                Session.Clear()
                Response.Redirect("~/login.aspx")
            End If

        End If
    End Sub


    'Protected Overrides Sub OnLoad(ByVal e As EventArgs)
    '    MyBase.OnLoad(e)
    '    Page.Header.DataBind()
    'End Sub


    Protected Sub btnLanguage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLanguage.Click

        Dim cookie As HttpCookie = New HttpCookie("Language")
        cookie.Value = btnLanguage.ToolTip
        Response.SetCookie(cookie)
        Response.Redirect(Request.UrlReferrer.AbsoluteUri)

    End Sub

End Class

